<%-- 
    Document   : response
    Created on : 18-ene-2009, 20:53:47
    Author     : germinus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:query var="stock_events" dataSource="jdbc/cardeacontrol">
    SELECT mt.mName,se.date,se.stock
    FROM stock_events as se, medicine_types mt
    WHERE se.medicineTypeId = mt.id
    <c:if test="${param.type_id != 0}">
        AND se.medicineTypeId = ? <sql:param value="${param.type_id}"/>
    </c:if>    
    order by date desc
    <%-- LIMIT ${(param.page-1)*3},${param.page*3} --%>
</sql:query>

<c:choose>
    <c:when test="${stock_events.rowCount == 0}">
        <table id="stock_results">
            <tr><td>No hay resultados</td></tr>
        </table>
    </c:when>
    <c:otherwise>
        <table id="stock_results"  width=70%>
            <thead>
                <tr>
                    <th sort="fecha">Fecha</th>
                    <th sort="medicamento">Medicamento</th>
                    <th sort="stock">Stock</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach var="stock_event" items="${stock_events.rows}">
                    <tr>
                        <td>${stock_event.date}</td>
                        <td>${stock_event.mName}</td>
                        <td>${stock_event.stock}</td>
                    </tr>
                </c:forEach>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan=3>
                        <div class="pagination"></div>
                        <div class="paginationTitle">P&aacute;gina</div>

                        <div class="selectPerPage"></div>
                        <div class="status"></div>
                    </td>
                </tr>
            </tfoot>

        </table>
    </c:otherwise>
</c:choose>



